_realname=highlight
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=4.4
pkgrel=1
url="http://www.andre-simon.de/doku/highlight/highlight.html"
pkgdesc="Fast and flexible source code highlighter (CLI version) (mingw-w64)"
license=('GPLv3')
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32')
depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs"
         "${MINGW_PACKAGE_PREFIX}-lua")
makedepends=("${MINGW_PACKAGE_PREFIX}-cc"
             "${MINGW_PACKAGE_PREFIX}-boost")
source=("https://gitlab.com/saalen/highlight/-/archive/v${pkgver}/highlight-v${pkgver}.tar.bz2"
        "001-fix-installation-prefix-and-destdir.patch"
        "002-fix-data-dir-stat.patch")
sha256sums=('c86a63db8c8a54a4e7f3fa941c2517fef6e0e15d494fe0bd154af49d98cf53e6'
            '13bfb4f326bd890c14c70c0fb30fc1d9ca7a0a8f0712f1c5e946bb59b942f3bb'
            '6104c02d1adc1728043c4514bb3105e98e693b28b76d9dd1d2711fe47ea6691d')

prepare() {
  cd "$srcdir/${_realname}-v${pkgver}/"
  patch -p1 -i "${srcdir}"/001-fix-installation-prefix-and-destdir.patch
  patch -p1 -i "${srcdir}"/002-fix-data-dir-stat.patch
}

build() {
  cp -r "$srcdir/${_realname}-v${pkgver}/" "${srcdir}"/build-${MSYSTEM}
  cd "${srcdir}"/build-${MSYSTEM}

  make PREFIX=${MINGW_PREFIX}
}

package() {
  cd "${srcdir}"/build-${MSYSTEM}
  DESTDIR="${pkgdir}" PREFIX=${MINGW_PREFIX} make install
}
